<extend name="Public/base" />

<block name="body">
	<!-- 标题栏 -->
	<div class="main-title">
		<h2>图书列表</h2>
	</div>
	<div class="cf">
		<div class="fl">
            <a class="btn" href="{:U('add')}">新 增</a>
        </div>

		<!-- 高级搜索 -->
        <form action="{:U('index')}" method="post" class="form-horizontal">
        
		<div class="search-form fr cf" style="width: 500px">
		 <label style="float: left; margin:5px">类别:</label>
		<select class="form-control" name="category" style="width: 30%;display: inline-block;float: left;">
					<volist name="Book_Category" id="vo" key="k" >
					<option value = {$k} <if condition="I('category')==$k">selected<else/></if>>{$vo}</option>
					</volist>
				</select>
			<div class="sleft" style="margin:2px">
				<input type="text" name="bookname" class="search-input" value="{:I('bookname')}" placeholder="请输入图书名称">
				<!-- <a class="sch-btn" href="javascript:;" id="search" url="{:U('index')}"><i class="btn-search"></i></a> -->
				<button class="sch-btn" id="submit" type="submit" target-form="{:U('index')}" style="border:0;background:#fff;"><i class="btn-search"></i></button>
			</div>
		</div>
		</form>
    </div>
    <!-- 数据列表 -->
    <div class="data-table table-striped">
	<table class="">
    <thead>
        <tr>
		<th class="">序号</th>
		<!-- <th class="">图书封面</th> -->
		<th class="">图书名称</th>
		<th class="">图书类别</th>
		<th class="">作者</th>
		<th class="">操作</th>
		</tr>
    </thead>
    <tbody>
		<notempty name="_list">
		<volist name="_list" id="vo">
		<tr>
			<td>{$key+1} </td>
			<!-- <td><img src="__ROOT__{$vo.cover}" style="height:100px;width: 75px;"></td> -->
			<td>{$vo.bookname}</td>
			<td><volist name="Book_Category" id="vos" key="k" >
					<if condition="$vo['category']==$k">{$vos}<else/></if>
					</volist>
						

			<td>{$vo.author}</td>
			<td><a href="{:U('Book/editBook?id='.$vo['id'])}" class="authorize">编辑</a>
				<a href="{:U('Book/questionList?bookid='.$vo['id'])}" class="authorize">题目</a>
                <a href="{:U('Book/deleteBook&id='.$vo['id'])}" class="confirm ajax-get">删除</a>
                </td>
		</tr>
		</volist>
		<else/>
		<td colspan="9" class="text-center"> aOh! 暂时还没有内容! </td>
		</notempty>
	</tbody>
    </table>
	</div>
    <div class="page">
        {$_page}
    </div>
</block>

<block name="script">
	<script src="__STATIC__/thinkbox/jquery.thinkbox.js"></script>

	<script type="text/javascript">
	//搜索功能
	$("#search").click(function(){
		var url = $(this).attr('url');
        var query  = $('.search-form').find('input').serialize();
        query = query.replace(/(&|^)(\w*?\d*?\-*?_*?)*?=?((?=&)|(?=$))/g,'');
        query = query.replace(/^&/g,'');
        if( url.indexOf('?')>0 ){
            url += '&' + query;
        }else{
            url += '?' + query;
        }
		window.location.href = url;
	});
	//回车搜索
	$(".search-input").keyup(function(e){
		if(e.keyCode === 13){
			$("#search").click();
			return false;
		}
	});
    //导航高亮
    highlight_subnav('{:U('Book/index')}');
	</script>
</block>
